
#include "uthread.h"
#include "linked.h"
#include "queue.h"
#include <stdlib.h>
#include <stdio.h>

void testB(int p)
{
    printf("I'm helping\n");
    uthread_exit();   
}

void testA(int c)
{
    printf("testA begins\n");
    uthread_yield();
    printf("testA creates a new thread\n");
    uthread_create(&testB, 4, 5);
    printf("testA yields\n");
    uthread_yield();
    printf("testA yields again\n");
    uthread_yield();
    printf("textA is about to exit\n"); 
    uthread_exit();
}


int main()
{

    printf("Calling init\n");
    uthread_init();
    printf("Creating testA's thread\n");
    uthread_create(&testA, 4, 5);
    printf("main yields\n");
    
    
    uthread_yield();
    printf("control returns to main, then yields\n");
    uthread_yield();
    printf("main yields again\n");
    uthread_yield();
    uthread_yield();
    printf("main is about to exit\n");
    uthread_yield();
    uthread_exit();
    printf("----->this should not print!\n");
    return 0;
}
